package com.yanqu.road.server.manger.activity.businessdepart;

import com.yanqu.road.dao.impl.activity.springdraw.SpringDrawConfigDaoImpl;
import com.yanqu.road.entity.activity.ActivityConfig;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.businessdepart.config.BusinessDepartConfig;
import com.yanqu.road.entity.activity.springdraw.config.SpringDrawConfig;
import com.yanqu.road.entity.activity.springdraw.config.SpringDrawDigRewardConfig;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.springdraw.SpringDrawModule;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import org.checkerframework.checker.units.qual.C;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class BusinessDepartMgr extends TempMgr {

    /**
     * 活动配置Map
     */
    private static Map<Integer, BusinessDepartConfig> businessDepartConfigMap = new ConcurrentHashMap<>();

    @Override
    public boolean init() throws Exception {
        return true;
    }

    @Override
    public boolean reloadConfig() throws Exception {
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        return true;
    }

    @Override
    public boolean stop() {
        return true;
    }

    /**
     * 加载活动
     */
    public static void reloadActivityData() {
        getLogger().info("reload BusinessDepartMgr start");
        //获取开启中的活动
        List<ActivityInfo> list = NormalActivityMgr.getOpenActivityInfoList(eActivityType.BusinessDepart.getValue());
        //创建活动配置
        if (list.isEmpty()) {
            return;
        }
        Map<Integer, BusinessDepartConfig> tempMap = new ConcurrentHashMap<>();
        for (ActivityInfo activityInfo : list) {
            Map<String, ActivityConfig> configMap = NormalActivityMgr.getActivityConfigMap(activityInfo.getActivityId());
            tempMap.put(activityInfo.getActivityId(), new BusinessDepartConfig(activityInfo, configMap));
        }
        businessDepartConfigMap = tempMap;
        getLogger().info("reload BusinessDepartMgr end");
    }

    /**
     * 获取配置
     * @return
     */
    public static BusinessDepartConfig getConfig(int activityId) {
        return businessDepartConfigMap.get(activityId);
    }

    /**
     * 获取配置MAP
     * @return
     */
    public static Map<Integer, BusinessDepartConfig> getConfigMap() {
        return businessDepartConfigMap;
    }
}
